<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>密保问题判定</title>
    <link rel="stylesheet" href="css/conmmon.css">
    <link rel="stylesheet" href="css/login.css">
    <style>
        .login-dialog {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

    </style>
    <script src="js/jquery.min.js"></script>
</head>

<body>
<!-- 导航栏 -->
<div class="nav">
    <img src="img/logo2.jpg" alt="">
    <span class="title">我的博客系统</span>
    <!-- 用来占据中间位置 -->
    <span class="spacer"></span>
    <a href="blog_list.html">主页</a>
    <a href="blog_edit.html">写博客</a>
    <a href="javascript:logout()">注销</a>
    <!-- <a href="#">注销</a> -->
</div>
<!-- 版心 -->
<div class="login-container">
    <!-- 中间的登陆框 -->
    <div class="login-dialog">
        <h3>密码确认</h3>
        <div class="row">
            <span>用户名</span>
            <input type="text" id="username" placeholder="用户名" autocomplete="off">
        </div>
        <div class="row">
            <span>密码</span>
            <input type="password" id="password" placeholder="密码" autocomplete="off">
        </div>
        <div class="row">
            <button id="submit" onclick="mysub()">确定</button>
        </div>
        
    </div>
</div>

<script>
       
        function mysub() {
            // 1. 非空校验
            var username = jQuery("#username");
            var password = jQuery("#password");
            var code = jQuery("#code");
            if (username.val() === "") {
                alert("用户名为空!")
                username.focus(); // 将鼠标光标设置到用户名控件
                return;
            }
            if (password.val() === "") {
                alert("密码为空!")
                password.focus(); // 将鼠标光标设置到密码控件
                return;
            }

            // 2. 发送 ajax 请求
            jQuery.ajax({
                // 请求的地址
                url:"/user/judgesecret",
                // 请求类型
                type:"POST",
                // 请求的参数
                data:{"username": username.val(), "password": password.val()},
                // 回调函数
                success:function(result) {
                    // 响应的结果
                    if (result != null && result.code === 200 && result.data != null) {
                        // 登录成功
                        location.href = "user_secret.html";
                    }  else {
                        alert("账号或密码不正确，请再次确认");
                    }
                }
            });
        }

    </script>
</body>

</html>